#!/bin/bash

cd `dirname $0`
if [ $# == 0 ];then
  echo "sh my_environment_centos7.sh sshd_config"
  echo "sh my_environment_centos7.sh vimrc"
  echo "sh my_environment_centos7.sh bash_profile"
  echo "sh my_environment_centos7.sh all"
  exit
fi


init_my_sshd_config_centos7(){
\cp -f /etc/ssh/sshd_config{,.bak}
if [ -f /etc/ssh/sshd_config.bak ];then
  \cp -f sshd_config_centos7 /etc/ssh/sshd_config
  echo "初始化sshd_config成功"
else
  echo "/etc/ssh/sshd_config.bak not exit"
  exit
fi
}

init_my_bash_profile(){
\cp -f ~/.bash_profile{,.bak}
if [ -f ~/.bash_profile.bak ];then
  \cp -f my_bash_profile ~/.bash_profile
  echo "初始化bash_profile成功"
  echo "请手动source ~/.bash_profile"
else
  echo "~/.bash_profile.bak not exit"
  exit
fi
}

init_my_vimrc(){
\cp -f ~/.vimrc{,.bak}
if [ -f ~/.vimrc.bak ];then
  \cp -f my_vimrc ~/.vimrc
  echo "初始化vimrc成功"
else
  echo "~/.bash_profile.bak not exit"
  exit
fi
}

if [ $1 == "all" ];then
  init_my_sshd_config_centos7
  init_my_bash_profile
  init_my_vimrc
  exit
  elif [ $1 == "sshd_config" ];then
  init_my_sshd_config_centos7
  exit
  elif [ $1 == "vimrc" ];then
  init_my_vimrc
  exit
  elif [ $1 == "bash_profile" ];then
  init_my_bash_profile
  exit
fi
